home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / manchest.lha / MANCHESTER / manchester / 2.2 / Form-combineWith:.st < prev    next >
Text File  |  1993-07-24  |  2KB  |  63 lines

  1. "    NAME        Form-combineWith:
  2.     AUTHOR        manchester
  3.     FUNCTION    ?
  4.     ST-VERSION    2.2
  5.     PREREQUISITES    
  6.     CONFLICTS
  7.     DISTRIBUTION    world
  8.     VERSION        1
  9.     DATE    22 Jan 1989"
  10. 'From Smalltalk-80, version 2, of April 1, 1983 on 23 January 1987 at 1:10:51 pm'!
  11.  
  12.  
  13.  
  14. !Form methodsFor: 'image manipulation'!
  15.  
  16. combineWith: aForm 
  17.     "Creates a new Form from the receiver and aForm, in the style  
  18.      of the demonstration on Page 386 of the Blue Book.  The two forms  
  19.      must be of the same size."
  20.  
  21.     | xStep yStep sourceBox destBox newForm mask flag |
  22.     self extent = aForm extent
  23.         ifFalse: [^self error: 'combineWith: form size must be the same'].
  24.     sourceBox _ self boundingBox.
  25.     xStep _ self extent x.
  26.     yStep _ self extent y.
  27.     newForm _ Form new extent: (xStep * 5) @ (yStep * 4).
  28.     destBox _ newForm boundingBox.
  29.  
  30.     0 to: 3 do: [ :xCount |
  31.         0 to: 3 do: [ :yCount |
  32.             flag _ false.
  33.             (xCount + yCount) = 0 ifTrue: [mask _ Form black.
  34.                 flag _ true].
  35.             (xCount + yCount) = 1 ifTrue: [mask _ Form darkGray.
  36.                 flag _ true].
  37.             (xCount + yCount) = 2 ifTrue: [mask _ Form gray.
  38.                 flag _ true].
  39.             (xCount + yCount) = 3 ifTrue: [mask _ Form lightGray.
  40.                 flag _ true].
  41.             flag ifTrue: [
  42.                 newForm copyBits: sourceBox
  43.                             from: self
  44.                             at: ((xStep * xCount)@(yStep * yCount))
  45.                             clippingBox: destBox
  46.                             rule: (Form over)
  47.                             mask: mask.
  48.                 newForm copyBits: sourceBox
  49.                             from: aForm
  50.                             at: ((xStep * (4 - xCount))@(yStep * (3 - yCount)))
  51.                             clippingBox: destBox
  52.                             rule: (Form over)
  53.                             mask: mask].
  54.         ]
  55.     ].
  56.     ^newForm
  57.  
  58. "
  59.     | tempForm |
  60.     tempForm _ Form readFrom: '/usr/r3/appl/PS/goodies/Manchester_goodies/ronnie.form'.
  61.     ((tempForm shrinkBy: (2@2)) combineWith: ((tempForm shrinkBy: (2@2)) reverse)) display.
  62. "! !
  63.